package com.teacold.customdemo.chapter_ten;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.RegionIterator;
import android.graphics.drawable.shapes.Shape;

public class RegionShape extends Shape {
    private Region mRegion;

    public RegionShape(Region mRegion) {
       assert(mRegion!=null);
        this.mRegion = mRegion;
    }

    @Override
    public void draw(Canvas canvas, Paint paint) {
        RegionIterator iterator=new RegionIterator(mRegion);
        Rect rect=new Rect();
        while (iterator.next(rect)){
            canvas.drawRect(rect,paint);
        }
    }


}
